﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Util.Common
{
    public class BaseWebConfig
    {
        /// <summary>
        ///根据webconfig key获取value
        /// </summary>
        /// <param name="appSettingName"></param>
        /// <returns></returns>
        protected static string GetAppSetting(string appSettingName)
        {
            if (ConfigurationManager.AppSettings[appSettingName] == null)
                return string.Empty;
            return ConfigurationManager.AppSettings[appSettingName];
        }
    }

    public class WebAppSettingConfig : BaseWebConfig
    {

        /// <summary>
        /// Redis服务器地址
        /// </summary>
        public static string RedisHostAddress
        {
            get { return GetAppSetting("RedisHostAddress"); }
        }
        /// <summary>
        /// Redis 服务器端口
        /// </summary>
        public static int RedisPort
        {
            get { return int.Parse(GetAppSetting("RedisPort")); }
        }
        /// <summary>
        /// Redis 密码
        /// </summary>
        public static string RedisPassword
        {
            get { return GetAppSetting("RedisPassword"); }
        }
    }
}
